package com.ruoyi.web.controller.comprehensive;

import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.github.pagehelper.PageInfo;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.comprehensive.domain.GasPrevention;
import com.ruoyi.comprehensive.dto.GasPreventionDto;
import com.ruoyi.comprehensive.dto.GasPreventionExamineDto;
import com.ruoyi.comprehensive.vo.GasPreventionExamineVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.comprehensive.domain.GasPreventionExamine;
import com.ruoyi.comprehensive.service.IGasPreventionExamineService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 瓦斯审核Controller
 * 
 * @author hcc
 * @date 2023-12-14
 */
@RestController
@RequestMapping("/comprehensive/gasExamine")
public class GasPreventionExamineController extends BaseController
{
    @Autowired
    private IGasPreventionExamineService gasPreventionExamineService;

    /**
     * 查询瓦斯审核列表
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:gasExamine:list')")
    @GetMapping("/list")
    public TableDataInfo list(GasPreventionExamine gasPreventionExamine)
    {
        startPage();
        List<GasPreventionExamine> list = gasPreventionExamineService.selectGasPreventionExamineList(gasPreventionExamine);
        return getDataTable(list);
    }

    /**
     * 导出瓦斯审核列表
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:gasExamine:export')")
    @Log(title = "瓦斯审核", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GasPreventionExamine gasPreventionExamine)
    {
        List<GasPreventionExamine> list = gasPreventionExamineService.selectGasPreventionExamineList(gasPreventionExamine);
        ExcelUtil<GasPreventionExamine> util = new ExcelUtil<GasPreventionExamine>(GasPreventionExamine.class);
        util.exportExcel(response, list, "瓦斯审核数据");
    }

    /**
     * 获取瓦斯审核详细信息
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:gasExamine:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(gasPreventionExamineService.selectGasPreventionExamineById(id));
    }

    /**
     * 新增瓦斯审核
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:gasExamine:add')")
    @Log(title = "瓦斯审核", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GasPreventionExamine gasPreventionExamine)
    {
        return toAjax(gasPreventionExamineService.insertGasPreventionExamine(gasPreventionExamine));
    }

    /**
     * 修改瓦斯审核
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:gasExamine:edit')")
    @Log(title = "瓦斯审核", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GasPreventionExamine gasPreventionExamine)
    {
        return toAjax(gasPreventionExamineService.updateGasPreventionExamine(gasPreventionExamine));
    }

    /**
     * 删除瓦斯审核
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:gasExamine:remove')")
    @Log(title = "瓦斯审核", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(gasPreventionExamineService.deleteGasPreventionExamineByIds(ids));
    }
    /**
     * 获取瓦斯审核详细信息
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:gasExamine:query')")
    @GetMapping("getGasPreventionExamineById/{id}")
    public AjaxResult getGasPreventionExamineById(@PathVariable("id") String id) {
        GasPreventionExamineDto gasPreventionExamineDto = gasPreventionExamineService.getGasPreventionExamineById(id);
        return success(gasPreventionExamineDto);
    }
    /**
     * 查询瓦斯审核列表
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:gasExamine:query')")
    @GetMapping("/getList")
    public TableDataInfo getList(GasPreventionExamineVo vo) {
        startPage();
        PageInfo<GasPreventionExamineDto> list = gasPreventionExamineService.getGasPreventionExamineList(vo);
        TableDataInfo rspData = new TableDataInfo();
        rspData.setCode(HttpStatus.SUCCESS);
        rspData.setMsg("查询成功");
        rspData.setRows(list.getList());
        rspData.setTotal(list.getTotal());
        return rspData;
    }
}
